﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace Beetle.Web
{
    /// <summary>
    /// Http处理模块,主要用来重定向到更改过的asp.net脚本,从而更改asp.net原始脚本
    /// </summary>
    /// <!-- 作者:韦腾  时间:2010年02月09日 -->
    public class WebResourceModule : IHttpModule
    {
        #region IHttpModule 成员

        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = sender as HttpApplication;
            HttpContext context = app.Context;

            string d = context.Request.QueryString["d"];
            d = Helper.DecryptString(d);
            ////自定义验证控件脚本
            if (d == "s|WebUIValidation.js")
            {
                string url = ResourceManager.HttpHandlerPath + "?type=r&f=Beetle.Web.WebUIValidation.js&lastModefiend=" + ResourceManager.LastModified;
                context.RewritePath(url);
            }
        }

        #endregion
    }
}
